package com.itheima.mapper;

import com.itheima.pojo.Clazz;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface ClazzMapper {

    List<Clazz> clazzpage(String name, LocalDate begin, LocalDate end);

    @Insert("insert into clazz (name,room,begin_date,end_date,master_id,subject,create_time,update_time) values (#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void add(Clazz clazz);


    //    @Select("select id,name,room,begin_date beginDate,end_date endDate,master_id masterId,subject,create_time createTime,update_time updateTime from clazz where id=#{id}")
    //    Clazz getInfo(Integer id);
    @Select("select * from clazz where  id = #{id}")
    Clazz getInfo(Integer id);


    void update(Clazz clazz);

    @Delete("delete from clazz where id = #{id}")
    void delete(Integer id);

    @Select("select id, name, room, begin_date beinDate, end_date endDate, master_id masterId, subject, create_time createTime, update_time updateTime from clazz")
    List<Clazz> list();


    @MapKey("name")
    List<Map<String, Object>> countStudentCountData();


}
